import 'package:flutter/material.dart';
import 'package:flutter_application_2/widgets/common_image.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

const List<String> imageList = [
  'https://ww3.sinaimg.cn/large/006y8mN6ly1g6e2tdgve1j30ku0bsn75.jpg',
  'https://ww3.sinaimg.cn/large/006y8mN6ly1g6e2whp87sj30ku0bstec.jpg',
  'https://ww3.sinaimg.cn/large/006y8mN6ly1g6e2tl1v3bj30ku0bs77z.jpg'
];
// 图片宽750px，高424px；

class CommonSwipper extends StatelessWidget {
  final List<String> images;
  const CommonSwipper({Key key, this.images = imageList}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    var height = MediaQuery.of(context).size.width / 750.0 * 424.0;
    return Container(
      height: height,
      child: Swiper(
        autoplay: true,
        itemBuilder: (BuildContext context, int index) {
          return CommonImage(
            images[index],
            fit: BoxFit.fill,
          );
        },
        itemCount: images.length,
        pagination: new SwiperPagination(),
        // control: new SwiperControl(),
      ),
    );
  }
}
